from app import app
from models import db, User

app.app_context().push()

def create_test_user():
    with app.app_context():
        # 检查是否已存在测试用户
        if User.query.filter_by(username='test').first():
            print("测试用户已存在")
            return
        
        # 创建测试用户
        user = User(username='test', password='test123')
        db.session.add(user)
        db.session.commit()
        print("测试用户创建成功")

if __name__ == '__main__':
    create_test_user()
